using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class test : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            throw new Exception("This is a test");
        }
        catch (Exception ex)
        {
            System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand();
            comm.Connection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DataManagerConnectionString"].ConnectionString);
            comm.CommandText = "INSERT INTO fstdt_exceptions (message, stacktrace) values (@message, @stacktrace)";
            comm.Parameters.AddWithValue("@message", ex.Message);
            comm.Parameters.AddWithValue("@stacktrace", ex.StackTrace);
            comm.Connection.Open();
            comm.ExecuteNonQuery();
            comm.Connection.Close();
            Button1.Text = "Done";
        }
    }
}
